card = {
		init:function(){
			if("undefined" != typeof(this.popbox)){
				return false;
			}
			var html = '<div class="layer user-card" id="showcard" style="display: none;position: absolute;z-index: 1000000;">'+
						'<div class="cmt-box" style="text-align:center"><img src="'+ _THEME_+'/css/img/main/icon_waiting.gif" width="15"></div>'+
						'</div>';
			this.popbox = $(html);
			$('body').append(this.popbox);
			this.usercard = new Array();
		},
		showCard:function(obj,uid) {
			this.init();
			this.obj = obj;
			$(obj).attr('show','yes');
			var _this = this;
			var _show = function(){
				//设置默认框的位置
				if($(obj).attr('show') != 'yes'){
					return false;
				}
				_this.setCss(obj);
				if("undefined" != typeof(_this.usercard[uid]) || _this.usercard[uid] == ''){
					_this.popbox.html(_this.usercard[uid]);
					_this.setCss(obj); //重设高宽
				}else{
					$.post(U('home/User/showUserCard'),{uid:uid},function(res) {
						_this.popbox.html(res);
						_this.setCss(obj); //重设高宽
						_this.usercard[uid] = res;
					});
				}
			};
			setTimeout(_show,800);
			$(obj).mouseover(function(){
				$(this).attr('show','yes');
			});
			$(obj).mouseout(function(){
				$(this).attr('show','no');
				_this.hide();
			});
		},
		setCss:function(obj){	//计算位置
			var p =$(obj).offset();
			var bh = $('body').height();
			var ww = $(window).width();
			var scrollHeight = $(window).scrollTop();
			var fw = this.popbox.width(); //可以设定 小名片的宽度
			var fh = this.popbox.height(); //可以设定 小名片的高度
			var top = p.top - fh - 40;
			var left = p.left;
			var children = this.popbox.children('#weizhi');
			if(ww-p.left < fw ){
				left = p.left - fw - 30;
				top = p.top - 25;
				children.css({'top':'14px'});
				children.removeClass('ab-down').addClass('ab-right');
			}
			if(p.top - scrollHeight < 40+fh){
				//向下
				//重设left
				top = p.top + $(obj).height() - 5;
				left = p.left ;
				children.removeAttr('style');
				children.removeClass('ab-down ab-right').addClass('ab-up');
			}
			if(bh-p.top < fh ||  ( $(window).height() +  scrollHeight - p.top) < fh ){
				//向上
				top = p.top - fh - 20;
				left = p.left;
				children.removeClass('ab ab-right').addClass('ab-down');
			}
			this.popbox.css({'left':left+'px','top':top+'px'})
			this.popbox.show();
			var _this = this;
			this.popbox.mouseover(function(){
				_this.boxOn = true;
			});
			this.popbox.mouseout(function(){
				_this.boxOn = false;
				_this.hide();
			});
		},
		hide:function(){
			var _this = this;
			var hidden = function(){
				if(_this.boxOn || $(_this.obj).attr('show') == 'yes'){
					return false;
				}
				_this.popbox.hide();
				$(_this.obj).attr('show','no');
			};
			setTimeout(hidden,250);
		}
};